package hpu.e4_demo.controller;

import hpu.e4_demo.common.Result;
import hpu.e4_demo.entity.Yuyue;
import hpu.e4_demo.service.YuyueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/yuyue")
public class YuyueController {
    @Autowired
    private YuyueService yuyueService;

    @PostMapping("/add")
    public Result<Yuyue> add(@RequestBody Yuyue yuyue) {
        return yuyueService.addYuyue(yuyue);
    }

    @GetMapping("/cancel")
    public Result<String> cancel(Integer id) {
        return yuyueService.cancelYuyue(id);
    }

    @GetMapping("/list")
    public Result<List<Yuyue>> list(Integer status) {
        return yuyueService.getYuyueList(status);
    }

    @GetMapping("/byCheliang")
    public Result<List<Yuyue>> byCheliang(Integer cheliangId) {
        return yuyueService.getYuyueByCheliangId(cheliangId);
    }

    @GetMapping("/byUser")
    public Result<List<Yuyue>> byUser(Integer userId) {
        return yuyueService.getYuyueByUserId(userId);
    }

    @GetMapping("/approve")
    public Result<String> approve(Integer id) {
        return yuyueService.approveYuyue(id);
    }

    @GetMapping("/reject")
    public Result<String> reject(Integer id) {
        return yuyueService.rejectYuyue(id);
    }
}